package web.Roles;

import com.google.gson.Gson;
import entity.RolesBean;
import services.RolesServiceAll;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/getRoleDataByUserId")
public class GetRoleDataByUserId extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("application/json");
        int uid = Integer.parseInt(req.getParameter("Uid"));
        RolesBean all = new RolesServiceAll().getRoleDataByUserId(uid);
        Gson gson = new Gson();
        String json = gson.toJson(all);
        resp.getWriter().println(json);
    }
}
